<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" type="text/css" th:href="@{/assets/edu/layui/css/layui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/assets/edu/css/css.css}">
    <script type="text/javascript" th:src="@{/assets/js/edu/jquery-1.11.3.js}"></script>
    <script type="text/javascript" th:src="@{/assets/edu/layui/layui.js}"></script>
</head>
<body th:inline="none">
<div class="pad10">
    <div class="layui-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <input type="hidden" th:value="${systemOpeningTime.id}" id="hid_id">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="start_time" th:value="${systemOpeningTime.startTime}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="end_time" th:value="${systemOpeningTime.endTime}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"></label>
                <button class="layui-btn" data-type="reset">更新系统开放时间</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['layer'], function () {
        var $ = layui.jquery;
        var active = {
            reset: function () {
                restTime();
            }
        };

        $('.layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    function restTime() {
        var id = $("#hid_id").val();
        var startTime = $("#start_time").val();
        var endTime = $("#end_time").val();
        if (startTime == null || startTime == "" || endTime == null || endTime == "") {
            layer.msg("开始时间或结束时间不能为空");
            return
        }
        layer.confirm('确定要更新系统开放时间吗？', {
            btn: ['确定', '取消']
        }, function (index, layero) {
            $.post("/systemOpeningTime/update",
                {
                    "id": id
                    , "startTime": startTime
                    , "endTime": endTime
                }, function (data) {
                    if (data.code != 90000) {
                        layer.msg("更新失败");
                    } else {
                        layer.msg("更新成功");
                    }
                });
        });
    }
</script>
</body>
</html>